/*******************************************************************************
*   Copyright (C) Harbin Institute of Technology, Shenzhen.
*				  All Rights Reserved.
*   Department: Decoration
********************************************************************************
* File Name   : ros.h
* Author      : Dayuan
* Version     : v0.01
* Date        : 2019/9/6
* Description : Decoration Rototics Manipulator task.
*******************************************************************************/
/*-History----------------------------------------------------------------------
* Version   Date      Name        Changes and comments
* v0.01     2019/9/6  Dayuan    initial version
*=============================================================================*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef _ROS_H_
#define _ROS_H_

#ifdef __cplusplus
 extern "C" {
#endif
     
/**** Includes ****/
#include <stdint.h>
/**** Definition of constants ****/
#define COM_RES_MAX		32767.0f
#define COM_RES_MAX_2	255.0f
#define COM_ANGLE_MAX 180.0f
#define COM_FORCE_MAX 2.0f
#define COM_K_MAX			10.0f
#define COM_D_MAX			1.0f

#define ROS_TX_BUFF_LEN 8
#define ROS_RX_BUFF_LEN 6


/**** Definition of types ****/ 
typedef enum
{
	COM_TYPE_ANGLE = 0,
	COM_TYPE_FORCE,
	COM_TYPE_K,
	COM_TYPE_D,
	COM_TYPE_OFFSET
}COM_DATA_TYPE;


typedef struct
{
	uint16_t head;
	uint16_t angle;
	uint16_t force;
	uint8_t status;
	uint8_t crc;
	uint8_t buff[8];
}ROS_TX;

/**** Definition of macros ****/

/**** Declaration of constants ****/


/**** Declaration of variables ****/

/**** Declaration of functions ****/
static int16_t float2int(float data ,COM_DATA_TYPE type);
static float int2float(int16_t data ,COM_DATA_TYPE type);
static int reset_ros(void);
static uint8_t enc_crc8_update(uint8_t crc, uint8_t data);
static uint8_t enc_tawa_crc_cal(uint8_t *buf, uint8_t size);

#ifdef __cplusplus
}
#endif

#endif
